public class Ticker implements Runnable {
	private Cache cache;
	private int interval = 1000;

	public Ticker(Cache cache) {
		this.cache = cache;
	}

	public void run() {
		synchronized (this) {
			while (true) {
				try {
					this.wait(interval);
					cache.send();
					//System.out.println("> 3 seconds wait now");
				} catch (InterruptedException e) {
					System.out.println("failed to wait: " + e);
				}
			}
		}
	}

	public void setInterval(int interval) {
		if (interval > 0 && interval < 60*60*1000) {
			this.interval = interval;
			System.out.println("sending interval is now " + interval);
		}
	}
}